package com.ag.zrt.action;

import javax.annotation.Resource;

import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.ag.bean.TbTaskStatus;
import com.ag.common.BaseAction;
import com.ag.zrt.service.TaskStatusService;
@Controller("addTaskStatusAction")
@Scope(BeanDefinition.SCOPE_PROTOTYPE)
public class AddTaskStatusAction extends BaseAction {

	/**
	 * 
	 */
	private static final long serialVersionUID = -6075802035513714340L;

	@Resource(name="TaskStatusService")
	private TaskStatusService taskStatusService;
	private TbTaskStatus taskStatus = new TbTaskStatus();
	private String tsName;
	private String msg;
	private String errorDetail;

	public void setTaskStatusService(TaskStatusService taskStatusService) {
		this.taskStatusService = taskStatusService;
	}

	public void setTsName(String tsName) {
		this.tsName = tsName;
	}

	@Override
	public String execute() {
		// TODO Auto-generated method stub
		try {

			taskStatus.setTsName(tsName);
			taskStatusService.save(taskStatus);
			msg = "添加成功";
			return "add_ts_succ";

		} catch (Exception e) {
			msg = "添加失败";
			errorDetail = e.toString();
			return "add_ts_failed";
		}
	}

	public String getMsg() {
		return msg;
	}

	public String getErrorDetail() {
		return errorDetail;
	}

}
